package com.jf.exam.service.impl;

import com.jf.exam.mapper.ExamQuestionMapper;
import com.jf.exam.pojo.vo.ExamQuestionVO;
import com.jf.exam.service.ExamQuestionService;
import com.jf.exam.service.ExamService;
import com.jf.exam.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("examQuestionService")
public class ExamQuestionServiceImpl implements ExamQuestionService {

    @Autowired
    ExamQuestionMapper examQuestionMapper;

    @Autowired
    ExamService examService;


    @Override
    public Result addExamQuestion(ExamQuestionVO examQuestionVO, Integer examId, int qScore) throws Exception {
        int count = examQuestionMapper.addExamQuestion(examQuestionVO);
        if (count > 0) {
            //更新试卷表
            int updateExamCount = examService.updateExamScore(examId, qScore, examQuestionVO.getFkQtype());
            if (updateExamCount > 0) {
                return Result.getSuccess("添加成功");
            }

        }
        return null;
    }
}
